<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>案例：输入分数，判定成绩等级</div>
    <input type="text" id="num1">
    <button id="btn">查询</button>
    <script>
        var num1 = document.getElementById("num1");
        var btn = document.getElementById("btn");
        btn.onclick = function () {
            var score = parseFloat(num1.value);
            if ( score <= 100 && score >= 80 ) {
                window.alert(score + "优秀");
            } else if ( score >= 70 && score < 80 ) {
                window.alert(score + "良好");
            } else if ( score >= 60 && score < 70 ) {
                window.alert(score + "及格");
            } else if ( score >= 0 && score < 60 ) {
                window.alert(score + "不及格");
            } else {
                window.alert("输入不符合规范");
            }
            num1.value = null;
        }
    </script>
</body>
</html>